package com.r_z.mapper;

import com.r_z.entity.Menu;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;
import java.util.Map;

/**
 * @author 梁俊
 * @date 2023/5/30
 * &@version 1.0
 */
@Mapper
public interface MenuMapper {

    /**
     * 查询父功能集合
     * @param map 集合
     * @return list 集合
     */
    @Select("SELECT m.*,u.`userName` FROM(SELECT * FROM users WHERE userName=#{userName}) u " +
            "INNER JOIN userRoleMenu urm ON u.`userRoleId`=urm.`userRoleId`" +
            "INNER JOIN(SELECT * FROM menu WHERE menuType='mainMenu') m ON urm.`menuId`=m.`menuId`")
    public List<Menu> selectMainMenu(Map map);

    /**
     * 根据父功能查子功能模块
     * @param map 集合
     * @return list 集合
     */
    @Select("SELECT m.*,u.`userName` FROM(SELECT * FROM users WHERE userName=#{userName}) u INNER JOIN userRoleMenu urm ON u.`userRoleId`=urm.`userRoleId` INNER JOIN(SELECT * FROM menu WHERE parentMenuId=#{parentMenuId} AND menuType='subMenu') m ON urm.`menuId`= m.`menuId`")
    public List<Menu>selectSubMenu(Map map);
}
